
package com.etop.beans;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity                             // Hibernate的映射，映射到数据库
@Table(name="user")                 // 名字必须与数据库user表名称一致
public class User {
    
    // 字段名称若与user表的字段名称不一致，要在get方法加上@Column，可参考下面例子
    
    private int id;                 // 数据库生成的id
    private String stuNum;          // 用户学号
    private String userName;        // 用户姓名
    private Integer gender;         // 用户性别  1代表男，0代表女
    private String password;        // 用户密码 
    private String userGrade;       // 用户班级(示例：12网工2班张三)
    private String address;         // 用户住址(示例：华山22-607)
    private String email;           // 用户Email
    private String tel;             // 用户联系方式
    private String gitAccount;      // 用户git账号
    private String blog;            // 用户博客
    private Integer isAdmin;        // 是否为管理员

    public User() {
    }

    public User(String stuNum, String password) {
        this.stuNum = stuNum;
        this.password = password;
    }

    
    
    

    @Id                                 // 主键，必须要有@Id
    @GeneratedValue                     // ID的生成策略，GenerateValue代表自动增长 
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the stuNum
     */
    @Column(name="stu_num")                         // 如果user表里的字段名称与实体类里的字段名称不一致
    public String getStuNum() {                    // 就要加上@Column(name="")映射到user表的stu_num字段
        return stuNum;
    }

    /**
     * @param stuNum the stuNum to set
     */
    public void setStuNum(String stuNum) {
        this.stuNum = stuNum;
    }

    /**
     * @return the userName
     */
    @Column(name="name")
    public String getUserName() {
        return userName;
    }

    /**
     * @param userName the userName to set
     */
    public void setUserName(String userName) {
        this.userName = userName;
    }

    /**
     * @return the gender
     */
    @Column(name="gender")
    public Integer getGender() {
        return gender;
    }

    /**
     * @param gender the gender to set
     */
    public void setGender(Integer gender) {
        this.gender = gender;
    }

    /**
     * @return the password
     */
    public String getPassword() {
        return password;
    }

    /**
     * @param password the password to set
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * @return the userClass
     */
    @Column(name="grade")
    public String getUserGrade() {
        return userGrade;
    }

    public void setUserGrade(String userGrade) {
        this.userGrade = userGrade;
    }

    /**
     * @return the address
     */
    public String getAddress() {
        return address;
    }

    /**
     * @param address the address to set
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @return the tel
     */
    public String getTel() {
        return tel;
    }

    /**
     * @param tel the tel to set
     */
    public void setTel(String tel) {
        this.tel = tel;
    }

    /**
     * @return the gitAccount
     */
    public String getGitAccount() {
        return gitAccount;
    }

    /**
     * @param gitAccount the gitAccount to set
     */
    public void setGitAccount(String gitAccount) {
        this.gitAccount = gitAccount;
    }

    /**
     * @return the blog
     */
    public String getBlog() {
        return blog;
    }

    /**
     * @param blog the blog to set
     */
    public void setBlog(String blog) {
        this.blog = blog;
    }

    /**
     * @return the isAdmin
     */
    public Integer getIsAdmin() {
        return isAdmin;
    }

    /**
     * @param isAdmin the isAdmin to set
     */
    public void setIsAdmin(Integer isAdmin) {
        this.isAdmin = isAdmin;
    }

    @Override
    public String toString() {
        return "User{" + "id=" + id + ", stuNum=" + stuNum + ", userName=" + userName + ", gender=" + gender + ", password=" + password + ", userGrade=" + userGrade + ", address=" + address + ", email=" + email + ", tel=" + tel + ", gitAccount=" + gitAccount + ", blog=" + blog + ", isAdmin=" + isAdmin + '}';
    }
    
    
}
